package drds.propagate.protocol;

/**
 * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry}
 *
 * <pre>
 * ***************************************************************
 * message model
 * 如果要在Enum中新增类型，确保以前的类型的下标值不变.
 * **************************************************************
 * </pre>
 */
public final class Entry extends
        com.google.protobuf.GeneratedMessage implements
        // @@protoc_insertion_point(message_implements:com.alibaba.otter.canal.protocol.Entry)
        CanalEntry.EntryOrBuilder {
    public static final int HEADER_FIELD_NUMBER = 1;
    public static final int ENTRYTYPE_FIELD_NUMBER = 2;
    public static final int STOREVALUE_FIELD_NUMBER = 3;
    private static final Entry defaultInstance;
    private static final long serialVersionUID = 0L;
    public static com.google.protobuf.Parser<Entry> PARSER =
            new com.google.protobuf.AbstractParser<Entry>() {
                public Entry parsePartialFrom(
                        com.google.protobuf.CodedInputStream input,
                        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                        throws com.google.protobuf.InvalidProtocolBufferException {
                    return new Entry(input, extensionRegistry);
                }
            };

    static {
        defaultInstance = new Entry(true);
        defaultInstance.initFields();
    }

    private final com.google.protobuf.UnknownFieldSet unknownFields;
    private int bitField0_;
    private CanalEntry.Header header_;
    private CanalEntry.EntryType entryType_;
    private com.google.protobuf.ByteString storeValue_;
    private byte memoizedIsInitialized = -1;
    private int memoizedSerializedSize = -1;

    // Use Entry.newBuilder() to construct.
    private Entry(com.google.protobuf.GeneratedMessage.Builder<?> builder) {
        super(builder);
        this.unknownFields = builder.getUnknownFields();
    }

    private Entry(boolean noInit) {
        this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance();
    }

    private Entry(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
        initFields();
        int mutable_bitField0_ = 0;
        com.google.protobuf.UnknownFieldSet.Builder unknownFields =
                com.google.protobuf.UnknownFieldSet.newBuilder();
        try {
            boolean done = false;
            while (!done) {
                int tag = input.readTag();
                switch (tag) {
                    case 0:
                        done = true;
                        break;
                    default: {
                        if (!parseUnknownField(input, unknownFields,
                                extensionRegistry, tag)) {
                            done = true;
                        }
                        break;
                    }
                    case 10: {
                        CanalEntry.Header.Builder subBuilder = null;
                        if (((bitField0_ & 0x00000001) == 0x00000001)) {
                            subBuilder = header_.toBuilder();
                        }
                        header_ = input.readMessage(CanalEntry.Header.PARSER, extensionRegistry);
                        if (subBuilder != null) {
                            subBuilder.mergeFrom(header_);
                            header_ = subBuilder.buildPartial();
                        }
                        bitField0_ |= 0x00000001;
                        break;
                    }
                    case 16: {
                        int rawValue = input.readEnum();
                        CanalEntry.EntryType value = CanalEntry.EntryType.valueOf(rawValue);
                        if (value == null) {
                            unknownFields.mergeVarintField(2, rawValue);
                        } else {
                            bitField0_ |= 0x00000002;
                            entryType_ = value;
                        }
                        break;
                    }
                    case 26: {
                        bitField0_ |= 0x00000004;
                        storeValue_ = input.readBytes();
                        break;
                    }
                }
            }
        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(this);
        } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(
                    e.getMessage()).setUnfinishedMessage(this);
        } finally {
            this.unknownFields = unknownFields.build();
            makeExtensionsImmutable();
        }
    }

    public static Entry getDefaultInstance() {
        return defaultInstance;
    }

    public static final com.google.protobuf.Descriptors.Descriptor
    getDescriptor() {
        return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor;
    }

    public static Entry parseFrom(
            com.google.protobuf.ByteString data)
            throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static Entry parseFrom(
            com.google.protobuf.ByteString data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Entry parseFrom(byte[] data)
            throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data);
    }

    public static Entry parseFrom(
            byte[] data,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
        return PARSER.parseFrom(data, extensionRegistry);
    }

    public static Entry parseFrom(java.io.InputStream input)
            throws java.io.IOException {
        return PARSER.parseFrom(input);
    }

    public static Entry parseFrom(
            java.io.InputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
        return PARSER.parseFrom(input, extensionRegistry);
    }

    public static Entry parseDelimitedFrom(java.io.InputStream input)
            throws java.io.IOException {
        return PARSER.parseDelimitedFrom(input);
    }

    public static Entry parseDelimitedFrom(
            java.io.InputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
        return PARSER.parseDelimitedFrom(input, extensionRegistry);
    }

    public static Entry parseFrom(
            com.google.protobuf.CodedInputStream input)
            throws java.io.IOException {
        return PARSER.parseFrom(input);
    }

    public static Entry parseFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws java.io.IOException {
        return PARSER.parseFrom(input, extensionRegistry);
    }

    public static Builder newBuilder() {
        return Builder.create();
    }

    public static Builder newBuilder(Entry prototype) {
        return newBuilder().mergeFrom(prototype);
    }

    public Entry getDefaultInstanceForType() {
        return defaultInstance;
    }

    @Override
    public final com.google.protobuf.UnknownFieldSet
    getUnknownFields() {
        return this.unknownFields;
    }

    protected FieldAccessorTable
    internalGetFieldAccessorTable() {
        return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable
                .ensureFieldAccessorsInitialized(
                        Entry.class, Builder.class);
    }

    @Override
    public com.google.protobuf.Parser<Entry> getParserForType() {
        return PARSER;
    }

    /**
     * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
     *
     * <pre>
     * *协议头部信息*
     * </pre>
     */
    public boolean hasHeader() {
        return ((bitField0_ & 0x00000001) == 0x00000001);
    }

    /**
     * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
     *
     * <pre>
     * *协议头部信息*
     * </pre>
     */
    public CanalEntry.Header getHeader() {
        return header_;
    }

    /**
     * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
     *
     * <pre>
     * *协议头部信息*
     * </pre>
     */
    public CanalEntry.HeaderOrBuilder getHeaderOrBuilder() {
        return header_;
    }

    /**
     * <code>optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = row_data];</code>
     *
     * <pre>
     * *打散后的事件类型*
     * </pre>
     */
    public boolean hasEntryType() {
        return ((bitField0_ & 0x00000002) == 0x00000002);
    }

    /**
     * <code>optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = row_data];</code>
     *
     * <pre>
     * *打散后的事件类型*
     * </pre>
     */
    public CanalEntry.EntryType getEntryType() {
        return entryType_;
    }

    /**
     * <code>optional bytes storeValue = 3;</code>
     *
     * <pre>
     * *传输的二进制数组*
     * </pre>
     */
    public boolean hasStoreValue() {
        return ((bitField0_ & 0x00000004) == 0x00000004);
    }

    /**
     * <code>optional bytes storeValue = 3;</code>
     *
     * <pre>
     * *传输的二进制数组*
     * </pre>
     */
    public com.google.protobuf.ByteString getStoreValue() {
        return storeValue_;
    }

    private void initFields() {
        header_ = CanalEntry.Header.getDefaultInstance();
        entryType_ = CanalEntry.EntryType.row_data;
        storeValue_ = com.google.protobuf.ByteString.EMPTY;
    }

    public final boolean isInitialized() {
        byte isInitialized = memoizedIsInitialized;
        if (isInitialized == 1) return true;
        if (isInitialized == 0) return false;

        memoizedIsInitialized = 1;
        return true;
    }

    public void writeTo(com.google.protobuf.CodedOutputStream output)
            throws java.io.IOException {
        getSerializedSize();
        if (((bitField0_ & 0x00000001) == 0x00000001)) {
            output.writeMessage(1, header_);
        }
        if (((bitField0_ & 0x00000002) == 0x00000002)) {
            output.writeEnum(2, entryType_.getNumber());
        }
        if (((bitField0_ & 0x00000004) == 0x00000004)) {
            output.writeBytes(3, storeValue_);
        }
        getUnknownFields().writeTo(output);
    }

    public int getSerializedSize() {
        int size = memoizedSerializedSize;
        if (size != -1) return size;

        size = 0;
        if (((bitField0_ & 0x00000001) == 0x00000001)) {
            size += com.google.protobuf.CodedOutputStream
                    .computeMessageSize(1, header_);
        }
        if (((bitField0_ & 0x00000002) == 0x00000002)) {
            size += com.google.protobuf.CodedOutputStream
                    .computeEnumSize(2, entryType_.getNumber());
        }
        if (((bitField0_ & 0x00000004) == 0x00000004)) {
            size += com.google.protobuf.CodedOutputStream
                    .computeBytesSize(3, storeValue_);
        }
        size += getUnknownFields().getSerializedSize();
        memoizedSerializedSize = size;
        return size;
    }

    @Override
    protected Object writeReplace()
            throws java.io.ObjectStreamException {
        return super.writeReplace();
    }

    public Builder newBuilderForType() {
        return newBuilder();
    }

    public Builder toBuilder() {
        return newBuilder(this);
    }

    @Override
    protected Builder newBuilderForType(
            BuilderParent parent) {
        Builder builder = new Builder(parent);
        return builder;
    }

    /**
     * Protobuf type {@code com.alibaba.otter.canal.protocol.Entry}
     *
     * <pre>
     * ***************************************************************
     * message model
     * 如果要在Enum中新增类型，确保以前的类型的下标值不变.
     * **************************************************************
     * </pre>
     */
    public static final class Builder extends
            com.google.protobuf.GeneratedMessage.Builder<Builder> implements
            // @@protoc_insertion_point(builder_implements:com.alibaba.otter.canal.protocol.Entry)
            CanalEntry.EntryOrBuilder {
        private int bitField0_;
        private CanalEntry.Header header_ = CanalEntry.Header.getDefaultInstance();
        private com.google.protobuf.SingleFieldBuilder<
                CanalEntry.Header, CanalEntry.Header.Builder, CanalEntry.HeaderOrBuilder> headerBuilder_;
        private CanalEntry.EntryType entryType_ = CanalEntry.EntryType.row_data;
        private com.google.protobuf.ByteString storeValue_ = com.google.protobuf.ByteString.EMPTY;

        // Construct using CanalEntry.Entry.newBuilder()
        private Builder() {
            maybeForceBuilderInitialization();
        }

        private Builder(
                BuilderParent parent) {
            super(parent);
            maybeForceBuilderInitialization();
        }

        public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
            return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor;
        }

        private static Builder create() {
            return new Builder();
        }

        protected FieldAccessorTable
        internalGetFieldAccessorTable() {
            return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_fieldAccessorTable
                    .ensureFieldAccessorsInitialized(
                            Entry.class, Builder.class);
        }

        private void maybeForceBuilderInitialization() {
            if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
                getHeaderFieldBuilder();
            }
        }

        public Builder clear() {
            super.clear();
            if (headerBuilder_ == null) {
                header_ = CanalEntry.Header.getDefaultInstance();
            } else {
                headerBuilder_.clear();
            }
            bitField0_ = (bitField0_ & ~0x00000001);
            entryType_ = CanalEntry.EntryType.row_data;
            bitField0_ = (bitField0_ & ~0x00000002);
            storeValue_ = com.google.protobuf.ByteString.EMPTY;
            bitField0_ = (bitField0_ & ~0x00000004);
            return this;
        }

        public Builder clone() {
            return create().mergeFrom(buildPartial());
        }

        public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
            return CanalEntry.internal_static_com_alibaba_otter_canal_protocol_Entry_descriptor;
        }

        public Entry getDefaultInstanceForType() {
            return Entry.getDefaultInstance();
        }

        public Entry build() {
            Entry result = buildPartial();
            if (!result.isInitialized()) {
                throw newUninitializedMessageException(result);
            }
            return result;
        }

        public Entry buildPartial() {
            Entry result = new Entry(this);
            int from_bitField0_ = bitField0_;
            int to_bitField0_ = 0;
            if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
                to_bitField0_ |= 0x00000001;
            }
            if (headerBuilder_ == null) {
                result.header_ = header_;
            } else {
                result.header_ = headerBuilder_.build();
            }
            if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
                to_bitField0_ |= 0x00000002;
            }
            result.entryType_ = entryType_;
            if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
                to_bitField0_ |= 0x00000004;
            }
            result.storeValue_ = storeValue_;
            result.bitField0_ = to_bitField0_;
            onBuilt();
            return result;
        }

        public Builder mergeFrom(com.google.protobuf.Message other) {
            if (other instanceof Entry) {
                return mergeFrom((Entry) other);
            } else {
                super.mergeFrom(other);
                return this;
            }
        }

        public Builder mergeFrom(Entry other) {
            if (other == Entry.getDefaultInstance()) return this;
            if (other.hasHeader()) {
                mergeHeader(other.getHeader());
            }
            if (other.hasEntryType()) {
                setEntryType(other.getEntryType());
            }
            if (other.hasStoreValue()) {
                setStoreValue(other.getStoreValue());
            }
            this.mergeUnknownFields(other.getUnknownFields());
            return this;
        }

        public final boolean isInitialized() {
            return true;
        }

        public Builder mergeFrom(
                com.google.protobuf.CodedInputStream input,
                com.google.protobuf.ExtensionRegistryLite extensionRegistry)
                throws java.io.IOException {
            Entry parsedMessage = null;
            try {
                parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
            } catch (com.google.protobuf.InvalidProtocolBufferException e) {
                parsedMessage = (Entry) e.getUnfinishedMessage();
                throw e;
            } finally {
                if (parsedMessage != null) {
                    mergeFrom(parsedMessage);
                }
            }
            return this;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public boolean hasHeader() {
            return ((bitField0_ & 0x00000001) == 0x00000001);
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public CanalEntry.Header getHeader() {
            if (headerBuilder_ == null) {
                return header_;
            } else {
                return headerBuilder_.getMessage();
            }
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public Builder setHeader(CanalEntry.Header value) {
            if (headerBuilder_ == null) {
                if (value == null) {
                    throw new NullPointerException();
                }
                header_ = value;
                onChanged();
            } else {
                headerBuilder_.setMessage(value);
            }
            bitField0_ |= 0x00000001;
            return this;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public Builder setHeader(
                CanalEntry.Header.Builder builderForValue) {
            if (headerBuilder_ == null) {
                header_ = builderForValue.build();
                onChanged();
            } else {
                headerBuilder_.setMessage(builderForValue.build());
            }
            bitField0_ |= 0x00000001;
            return this;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public Builder mergeHeader(CanalEntry.Header value) {
            if (headerBuilder_ == null) {
                if (((bitField0_ & 0x00000001) == 0x00000001) &&
                        header_ != CanalEntry.Header.getDefaultInstance()) {
                    header_ =
                            CanalEntry.Header.newBuilder(header_).mergeFrom(value).buildPartial();
                } else {
                    header_ = value;
                }
                onChanged();
            } else {
                headerBuilder_.mergeFrom(value);
            }
            bitField0_ |= 0x00000001;
            return this;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public Builder clearHeader() {
            if (headerBuilder_ == null) {
                header_ = CanalEntry.Header.getDefaultInstance();
                onChanged();
            } else {
                headerBuilder_.clear();
            }
            bitField0_ = (bitField0_ & ~0x00000001);
            return this;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public CanalEntry.Header.Builder getHeaderBuilder() {
            bitField0_ |= 0x00000001;
            onChanged();
            return getHeaderFieldBuilder().getBuilder();
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        public CanalEntry.HeaderOrBuilder getHeaderOrBuilder() {
            if (headerBuilder_ != null) {
                return headerBuilder_.getMessageOrBuilder();
            } else {
                return header_;
            }
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.Header header = 1;</code>
         *
         * <pre>
         * *协议头部信息*
         * </pre>
         */
        private com.google.protobuf.SingleFieldBuilder<
                CanalEntry.Header, CanalEntry.Header.Builder, CanalEntry.HeaderOrBuilder>
        getHeaderFieldBuilder() {
            if (headerBuilder_ == null) {
                headerBuilder_ = new com.google.protobuf.SingleFieldBuilder<
                        CanalEntry.Header, CanalEntry.Header.Builder, CanalEntry.HeaderOrBuilder>(
                        getHeader(),
                        getParentForChildren(),
                        isClean());
                header_ = null;
            }
            return headerBuilder_;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = row_data];</code>
         *
         * <pre>
         * *打散后的事件类型*
         * </pre>
         */
        public boolean hasEntryType() {
            return ((bitField0_ & 0x00000002) == 0x00000002);
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = row_data];</code>
         *
         * <pre>
         * *打散后的事件类型*
         * </pre>
         */
        public CanalEntry.EntryType getEntryType() {
            return entryType_;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = row_data];</code>
         *
         * <pre>
         * *打散后的事件类型*
         * </pre>
         */
        public Builder setEntryType(CanalEntry.EntryType value) {
            if (value == null) {
                throw new NullPointerException();
            }
            bitField0_ |= 0x00000002;
            entryType_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional .com.alibaba.otter.canal.protocol.EntryType entryType = 2 [default = row_data];</code>
         *
         * <pre>
         * *打散后的事件类型*
         * </pre>
         */
        public Builder clearEntryType() {
            bitField0_ = (bitField0_ & ~0x00000002);
            entryType_ = CanalEntry.EntryType.row_data;
            onChanged();
            return this;
        }

        /**
         * <code>optional bytes storeValue = 3;</code>
         *
         * <pre>
         * *传输的二进制数组*
         * </pre>
         */
        public boolean hasStoreValue() {
            return ((bitField0_ & 0x00000004) == 0x00000004);
        }

        /**
         * <code>optional bytes storeValue = 3;</code>
         *
         * <pre>
         * *传输的二进制数组*
         * </pre>
         */
        public com.google.protobuf.ByteString getStoreValue() {
            return storeValue_;
        }

        /**
         * <code>optional bytes storeValue = 3;</code>
         *
         * <pre>
         * *传输的二进制数组*
         * </pre>
         */
        public Builder setStoreValue(com.google.protobuf.ByteString value) {
            if (value == null) {
                throw new NullPointerException();
            }
            bitField0_ |= 0x00000004;
            storeValue_ = value;
            onChanged();
            return this;
        }

        /**
         * <code>optional bytes storeValue = 3;</code>
         *
         * <pre>
         * *传输的二进制数组*
         * </pre>
         */
        public Builder clearStoreValue() {
            bitField0_ = (bitField0_ & ~0x00000004);
            storeValue_ = getDefaultInstance().getStoreValue();
            onChanged();
            return this;
        }

        // @@protoc_insertion_point(builder_scope:com.alibaba.otter.canal.protocol.Entry)
    }

    // @@protoc_insertion_point(class_scope:com.alibaba.otter.canal.protocol.Entry)
}
